package com.woniu.service.impl;

import com.sun.javafx.collections.MappingChange;
import com.woniu.dao.RbacManagerDao;
import com.woniu.entity.RbacManager;


import com.woniu.service.RbacManagerService;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;
import java.util.Objects;


/**
 * @author:陈涵
 * @Do:
 * @date: 2022/8/25 16:46
 */
public class RbacManagerServiceImpl implements RbacManagerService {
    private RbacManagerDao rbacManagerDao;

    public void setRbacManagerDao(RbacManagerDao rbacManagerDao) {
        this.rbacManagerDao = rbacManagerDao;
    }

    @Override
    public RbacManager findOne(int id) {
        System.out.println("这个是一个日志：我记录了id是："+id+"的用户的查询操作！");
        RbacManager one = rbacManagerDao.findOne(id);
        if (Objects.nonNull(one)){
            System.out.println("查询"+id+"用户成功！");
        }else {
            System.out.println("查询"+id+"用户失败！");
        }
        return one;
    }

    @Override
    public List<RbacManager> findAll() {
        //dao没注册吗
        List<RbacManager> all = rbacManagerDao.findAll();
        all.forEach(System.out::println);
        return all;
    }

    @Override
    @Transactional
    public int addOne(RbacManager rbacManager) {
        int i = rbacManagerDao.addOne(rbacManager);
        return i;
    }

    @Override
    public int updateOne(RbacManager rbacManager) {
        return rbacManagerDao.updateOne(rbacManager);
    }

    @Override
    public int deleteOne(int id) {
        return rbacManagerDao.deleteOne(id);
    }

    @Override
    public List<RbacManager> findByName(String username) {
        return rbacManagerDao.findOneByLikeName(username);
    }

    @Override
    public List<RbacManager> findByIds(Integer[] ids) {
        return rbacManagerDao.findByIds(ids);
    }

    @Override
    public int addOneForMap(Map<String, Object> userinfo) {
        return rbacManagerDao.addOneForMap((Map<String, Object>) userinfo);
    }
}
